#include "logger.h"
#include <stdarg.h>

// 当前日志级别
static LogLevel current_log_level = LOG_INFO;

// 设置日志级别
void set_log_level(LogLevel level) {
    current_log_level = level;
}

// 日志函数
void log_message(LogLevel level, const char *format, ...) {
    if (level < current_log_level) {
        return;
    }

    const char *level_str;
    switch (level) {
        case LOG_DEBUG:
            level_str = "DEBUG";
            break;
        case LOG_INFO:
            level_str = "INFO";
            break;
        case LOG_WARN:
            level_str = "WARN";
            break;
        case LOG_ERROR:
            level_str = "ERROR";
            break;
        default:
            level_str = "UNKNOWN";
            break;
    }

    va_list args;
    va_start(args, format);

    printf("[%s] ", level_str);
    vprintf(format, args);
    printf("\n");

    va_end(args);
}